package com.xmall.controller.admin;

import com.xmall.bean.vo.BaseRespVo;
import com.xmall.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author Connor
 * @ClassName: ConfigController
 * @PackageName: com.xmall.controller
 * @date 2020/12/06
 * @Version 1.0
 */
@RestController
@RequestMapping("admin/config")
public class ConfigController {

    @Autowired
    ConfigService configService;

    @GetMapping("mall")
    public BaseRespVo queryMallConfiguration() {
        Map<String, String> map = configService.queryMallConfiguration();
        return BaseRespVo.ok(map);
    }

    @PostMapping("mall")
    public BaseRespVo updateMallConfiguration(@RequestBody Map<String, String> map) {
        configService.updateMallConfiguration(map);
        return BaseRespVo.ok();
    }

    @GetMapping("express")
    public BaseRespVo queryExpressConfiguration() {
        Map<String, String> map = configService.queryExpressConfiguration();
        return BaseRespVo.ok(map);
    }

    @PostMapping("express")
    public BaseRespVo updateExpressConfiguration(@RequestBody Map<String, String> map) {
        configService.updateExpressConfiguration(map);
        return BaseRespVo.ok();
    }

    @GetMapping("order")
    public BaseRespVo queryOrderConfiguration() {
        Map<String, String> map = configService.queryOrderConfiguration();
        return BaseRespVo.ok(map);
    }

    @PostMapping("order")
    public BaseRespVo updateOrderConfiguration(@RequestBody Map<String, String> map) {
        configService.updateOrderConfiguration(map);
        return BaseRespVo.ok();
    }

    @GetMapping("wx")
    public BaseRespVo queryWxConfiguration() {
        Map<String, String> map = configService.queryWxConfiguration();
        return BaseRespVo.ok(map);
    }

    @PostMapping("wx")
    public BaseRespVo updateWxConfiguration(@RequestBody Map<String, String> map) {
        configService.updateWxConfiguration(map);
        return BaseRespVo.ok();
    }
}
